<div id="<?= $name;?>" class="ctype-field">
<?php $conf_label = array(); ?>
<?php if(form_error($name)): ?>
	<?php $conf_label['class'] = "input_error"; ?>
<?php endif; ?>
		
<?php $title_label = $properties['title']; ?>
<?php if(isset($required) && $required): ?>
	<?php $title_label .=  " *"; ?>
<?php endif; ?>
<?= form_label($title_label, $name, $conf_label); ?>

<select name="<?= $name?>[]" multiple="multiple" id="select_<?= $name?>">
	<?php foreach($tags as $tag): ?>
	<option value="<?= $tag->id; ?>" <?php if(isset($selected_tags) && isTagSelected($tag->id, $selected_tags)) echo 'class="selected"'; ?>><?= $tag->name; ?></option>
	<?php endforeach;?>
</select>

</div>

<script type="text/javascript">
$(document).ready(function() {        
          
	$("#select_<?= $name?>").fcbkcomplete({
		cache: true,
		filter_case: true,
		filter_hide: true,
		firstselected: true,
		filter_selected: true,
		newel: true,
		complete_text: "Comienza a escribir..."  
	});		 
});
</script>

<?php 

	function isTagSelected($id, $tags){
		if(isset($tags)){
			foreach($tags as $node_tag){
				if($id == $node_tag->id){
					return TRUE;
				}
			}	
		}
	
		return FALSE;
	}	
?>
